Communications 108

After the reader presses the button below, I'll prompt the user to say hello.

Discussion

This eighth "hello" program asks the user for a response by exercising the prompt() function. This script converts the response to uppercase to compare against the string "HELLO". The script notifies the user with this comparison.

Creating a popup window

function doHello(msg)
{
    var ans = prompt(""+msg,"Hello");
    
    if (!ans) alert("You pressed cancel.")
    else if (ans.toUpperCase() == "HELLO") alert("You said hello!")
    else alert("You didn't say hello...")
}
Copyright ©1998 by Charles River Media, All Rights Reserved